#ifndef TCPSOCKETDIALOG_H
#define TCPSOCKETDIALOG_H

#include <QDialog>
#include <QTcpSocket>
#include <QDataStream>
#include <QTimer>
#include <QTime>

namespace Ui {
class TcpSocketDialog;
}

class TcpSocketDialog : public QDialog
{
    Q_OBJECT

public:
    explicit TcpSocketDialog(QTcpSocket *socket, QWidget *parent = 0);
    ~TcpSocketDialog();

protected:
    void do_connect();
    void do_disconnect();

private slots:
    void on_readyRead();
    void on_disconnected();
    void on_stateChanged(QAbstractSocket::SocketState);
    void on_error(QAbstractSocket::SocketError);

private slots:
    void on_btn_Disconnect_clicked();

    void on_btn_Send_clicked();

    void on_btn_Stop_clicked();

private:
    Ui::TcpSocketDialog *ui;

    QTcpSocket *tcpSocket;
    QDataStream stream;
    QTimer autoWriter;
    int count = 0;
    QTimer speedCalc;
    int bytes = 0;
    QTime time;
};

#endif // TCPSOCKETDIALOG_H
